﻿'This interface allow the MapWindow plugin to launch WRDB remotely

<CLSCompliant(True)> _
Public Interface clsWRDB
    Sub ShowMainFormMW()
    Function GetMainFormMW() As System.Windows.Forms.Form
    Sub CloseMainFormMW()
    Event Closed()
    Sub MapMouseMove(ByVal ScreenX As Integer, ByVal ScreenY As Integer)
    Sub MapExtentsChanged()
    Sub ShapesSelected()
End Interface

Public Interface clsGraph

    ''' <summary>
    ''' List of allowable graph types to be displayed by frmGraph
    ''' </summary>
    Enum enumGraphType
        TimeSeries
        Profile
        Depth
        Width
        Scatter
        Histogram
        Probability
        FlowDuration
    End Enum

    Sub ShowGraph(OwnerForm As Form, ProjectName As String, TableName As String, GraphType As enumGraphType, BypassManageSeries As Boolean, SqlString As String)

    Sub ShowGraph(Optional OwnerForm As Form = Nothing, Optional GraphFile As String = "", Optional LoadLast As Boolean = False, Optional FormCaption As String = "WRDB Graph")

    Sub ShowGraph(OwnerForm As Form, BMDFile As String, GraphType As enumGraphType, BypassManageSeries As Boolean, Optional FormCaption As String = "WRDB Graph")

    Sub AddSeries(StationID As String, PCode As String, Optional DepthPCode As String = "Depth")

    Sub AddSeries(BranchID As String, dictProfile As Generic.Dictionary(Of Double, String), PCode As String, DateTime As Date)

    'Sub SetAnimationTimestep(Timestep As Integer)

    'Sub ShowGraphControls(tf As Boolean)

End Interface

Public Interface clsGIS

    ''' <summary>
    ''' Controls how data are displayed in GIS form
    ''' </summary>
    Enum enumMode
        ''' <summary>Display all stations from support table</summary>
        DisplayStations

        ''' <summary>Select from all stations found in browser</summary>
        SelectStations

        ''' <summary>Display summary from last query</summary>
        OutputData

        ''' <summary>Allow data files to be loaded and associated with polygon shapefile; disables display of WRDB Stations data</summary>
        Animate

        ''' <summary>Allow selection of lat/long rectangle</summary>
        AreaOfInterest

        ''' <summary>Display all stations supplied in tab-separated list like Station ID/Name(tab)Latitude(tab)Longitude</summary>
        StationsList

        ''' <summary>Select from polygons displayed on map</summary>
        SelectPolygons
    End Enum

    Sub ShowGIS(OwnerForm As Form, Mode As enumMode, StationList As Generic.List(Of String), Basemap As String)

    Sub ShowGIS(OwnerForm As Form, GisFile As String, LoadLast As Boolean)

End Interface

Public Class clsAccessWRDB
    Const REGAPP As String = "WRDB6"

    Public Shared Function DLLPath() As String
        If False And Diagnostics.Debugger.IsAttached And Environment.UserName.Contains("LCW") Then
            Return "D:\Projects\WRDB 6.0\bin"
        Else
            Return GetSetting(REGAPP, "Defaults", "DLL Path 6.1", "C:\Water Resources Database 6.1")
        End If
    End Function

    Public Shared Function WRDBIsInstalled(Optional ByRef ErrorMsg As String = "") As Boolean
        If IO.Directory.Exists(DLLPath) AndAlso IO.File.Exists(DLLPath() & "\WRDB.exe") Then
            ErrorMsg = ""
            Return True
        Else
            ErrorMsg = String.Format("Unable to find the necessary WRDB libraries in the expected directory ({0}). You must download and install WRDB 6 for this program to run properly (it is available at www.wrdb.com). If you have installed the latest version of WRDB into a non-default drive or directory, you must run the stand-alone version of WRDB 6 at least once so it can register its location and thus allow this application to find it.", DLLPath)
            Return False
        End If
    End Function

    Public Shared Function LaunchWRDB() As Boolean
        If WRDBIsInstalled() Then
            Shell(DLLPath() & "\WRDB.exe", AppWinStyle.NormalFocus)
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function LaunchWRDBGraph(Optional GraphFile As String = "") As Boolean
        If WRDBIsInstalled() Then
            GraphFile = GraphFile.Trim
            If GraphFile.Contains(" ") And Not GraphFile.StartsWith("""") Then GraphFile = """" & GraphFile & """"
            If GraphFile <> "" Then GraphFile = " " & GraphFile
            Shell(DLLPath() & "\WRDBGraph.exe" & GraphFile, AppWinStyle.NormalFocus)
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function LaunchWRDBGIS(Optional GISFile As String = "") As Boolean
        If WRDBIsInstalled() Then
            GISFile = GISFile.Trim
            If GISFile.Contains(" ") And Not GISFile.StartsWith("""") Then GISFile = """" & GISFile & """"
            If GISFile <> "" Then GISFile = " " & GISFile
            Shell(DLLPath() & "\WRDBGIS.exe" & GISFile, AppWinStyle.NormalFocus)
            Return True
        Else
            Return False
        End If
    End Function

End Class

